﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TXTD.Admin.Model.Core
{
    /// <summary>
    /// 返回数据模型
    /// </summary>
    public class ResultModel
    {
        /// <summary>
        /// 访问状态
        /// </summary>
        public int Code { get; set; } = 200;
        /// <summary>
        /// 是否成功
        /// </summary>
        public bool Success { get; set; } = true;
        /// <summary>
        /// 返回消息
        /// </summary>
        public string Message { get; set; } = "执行成功";
        /// <summary>
        /// 错误信息
        /// </summary>
        public string? Error { get; set; }
        /// <summary>
        /// 异常信息
        /// </summary>
        public string? ExceptionInfo { get; set; }
        /// <summary>
        /// 错误类型
        /// </summary>
        public string? ErrorType { get; set; }
        /// <summary>
        /// 结果
        /// </summary>
        public object? Result { get; set; }
        /// <summary>
        /// 其他附加信息
        /// </summary>
        public object? OtherInfo { get; set; }
        /// <summary>
        /// 根据执行结果返回
        /// </summary>
        /// <param name="count">数据影响行数</param>
        /// <returns></returns>
        public static ResultModel ResultByCount(int count)
        {
            ResultModel result = new ResultModel();
            if (count < 0)
                result.Success = false;
            return result;
        }
        /// <summary>
        /// 根据执行结果返回
        /// </summary>
        /// <param name="Result">执行结果</param>
        /// <returns></returns>
        public static ResultModel ResultBy(object Result)
        {
            ResultModel result = new ResultModel();
            result.Result = Result;
            return result;
        }
    }
}
